using System.Linq;
using Magiq.Tests;
using Magiq.Tests.Sql.TestModel;
using Magiq.Tests.Support;
using NUnit.Framework;

namespace Magiq.Tests.Sql
{
    [TestFixture]
    public class MagiqToSqlDeletesTest : BaseMagiqProviderDeletesTest<LinqToSqlTestClass>
    {
        protected override IMagiqTestConfigurator GetConfigurator()
        {
            return MagiqToSqlTestConfigurator.Current;
        }

        [Test]
        public void ShouldDeleteWhereThatUsesReference()
        {
            var r = ReferenceClassInstances.First();
            var items = TestClassInstances.Where(x => x.Reference == r);
            var count = items.Count();
            items.Delete().Should(Be.EqualTo(count));
        }
    }
}